home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / fish / 001-100 / 001-025 / 022 / lemacs / ansi.c next >
C/C++ Source or Header  |  1995-03-17  |  3KB  |  131 lines

  1. /*
  2.  * The routines in this file provide support for ANSI style terminals
  3.  * over a serial line. The serial I/O services are provided by routines in
  4.  * "termio.c". It compiles into nothing if not an ANSI device.
  5.  */
  6.  
  7. #define    termdef    1            /* don't define "term" external */
  8.  
  9. #include        <stdio.h>
  10. #include    "estruct.h"
  11. #include        "edef.h"
  12.  
  13. #if     ANSI
  14.  
  15. #if    AMIGA
  16. #define NROW    23                      /* Screen size.                 */
  17. #define NCOL    77                      /* Edit if you want to.         */
  18. #else
  19. #define NROW    25                      /* Screen size.                 */
  20. #define NCOL    80                      /* Edit if you want to.         */
  21. #endif
  22. #define    MARGIN    8            /* size of minimim margin and    */
  23. #define    SCRSIZ    64            /* scroll size for extended lines */
  24. #define BEL     0x07                    /* BEL character.               */
  25. #define ESC     0x1B                    /* ESC character.               */
  26.  
  27. extern  int     ttopen();               /* Forward references.          */
  28. extern  int     ttgetc();
  29. extern  int     ttputc();
  30. extern  int     ttflush();
  31. extern  int     ttclose();
  32. extern  int     ansimove();
  33. extern  int     ansieeol();
  34. extern  int     ansieeop();
  35. extern  int     ansibeep();
  36. extern  int     ansiopen();
  37. extern    int    ansirev();
  38. /*
  39.  * Standard terminal interface dispatch table. Most of the fields point into
  40.  * "termio" code.
  41.  */
  42. TERM    term    = {
  43.         NROW-1,
  44.         NCOL,
  45.     MARGIN,
  46.     SCRSIZ,
  47.         ansiopen,
  48.         ttclose,
  49.         ttgetc,
  50.         ttputc,
  51.         ttflush,
  52.         ansimove,
  53.         ansieeol,
  54.         ansieeop,
  55.         ansibeep,
  56.     ansirev
  57. };
  58.  
  59. ansimove(row, col)
  60. {
  61.         ttputc(ESC);
  62.         ttputc('[');
  63.         ansiparm(row+1);
  64.         ttputc(';');
  65.         ansiparm(col+1);
  66.         ttputc('H');
  67. }
  68.  
  69. ansieeol()
  70. {
  71.         ttputc(ESC);
  72.         ttputc('[');
  73.         ttputc('K');
  74. }
  75.  
  76. ansieeop()
  77. {
  78.         ttputc(ESC);
  79.         ttputc('[');
  80.         ttputc('J');
  81. }
  82.  
  83. ansirev(state)        /* change reverse video state */
  84.  
  85. int state;    /* TRUE = reverse, FALSE = normal */
  86.  
  87. {
  88.     ttputc(ESC);
  89.     ttputc('[');
  90.     ttputc(state ? '7': '0');
  91.     ttputc('m');
  92. }
  93.  
  94. ansibeep()
  95. {
  96.         ttputc(BEL);
  97.         ttflush();
  98. }
  99.  
  100. ansiparm(n)
  101. register int    n;
  102. {
  103.         register int    q;
  104.  
  105.         q = n/10;
  106.         if (q != 0)
  107.                 ansiparm(q);
  108.         ttputc((n%10) + '0');
  109. }
  110.  
  111. #endif
  112.  
  113. ansiopen()
  114. {
  115. #if     V7
  116.         register char *cp;
  117.         char *getenv();
  118.  
  119.         if ((cp = getenv("TERM")) == NULL) {
  120.                 puts("Shell variable TERM not defined!");
  121.                 exit(1);
  122.         }
  123.         if (strcmp(cp, "vt100") != 0) {
  124.                 puts("Terminal type not 'vt100'!");
  125.                 exit(1);
  126.         }
  127. #endif
  128.     revexist = TRUE;
  129.         ttopen();
  130. }
  131.